<%@ page import="database.ClassDb" %>
<%@ page import="database.Class" %>
<%@ page import="java.util.List" %>
<%@ page import="utils.StringUtils" %>
<%@ page import="java.io.PrintWriter" %><%--
  Created by IntelliJ IDEA.
  User: jimmyhsu
  Date: 2016/12/12
  Time: 23:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="../../static/style/weui.css"/>
    <link rel="stylesheet" href="../../static/example/example.css"/>
    <link rel="stylesheet" href="../../static/style/myStyle.css"/>
    <%
        List<Class> allClasses = ClassDb.selectAllClasses();
        String classId = request.getParameter("classId");
        String className = StringUtils.getUtf8String(request.getParameter("className"));
        String show = StringUtils.getUtf8String(request.getParameter("show"));
        PrintWriter writer = response.getWriter();
        if (!StringUtils.isEmpty(classId)) {
            writer.print("<script>window.parent.mainweb.left_frame.location.href='importClassLeft.jsp?classId="+classId+"';</script>");
            writer.print("<script>window.parent.mainweb.right_frame.location.href='importClassRight.jsp?classId="+classId+"';</script>");
        }
    %>
</head>
<body style="background-color: transparent; color: #ffffff">
<%@include file="Do/checkAdminLogin.jsp"%>
<br>&nbsp;
<img src="../../static/image/arrow1.png" style="-ms-transform:rotate(90deg); /* IE 9 */
    -moz-transform:rotate(90deg); /* Firefox */
    -webkit-transform:rotate(90deg); /* Safari and Chrome */
    -o-transform:rotate(90deg); /* Opera */" onclick="goback()">
    <center>
        <h1 class = "page_title">导入或查询班级</h1>
        <p class="page_desc">
            已存在的班级：
            <%
			for (Class aClass : allClasses) {%>
            <%=aClass.getName()%>&nbsp;
            <%
			}
			%>
        </p>
        班级名称
        <% if(StringUtils.isEmpty(classId)) {%>
        <input type = "text" name = "className" id="className" />
        <button class="weui_btn weui_btn_mini weui_btn_default" style = "position: relative" onclick='onAdd()'>查询或添加</button>
        <% }else{%>
          <a href="#"><%=className%></a>
        <%}%>
        <%=" " + (StringUtils.isEmpty(show) ? "" : show)%>
    </center>

</body>
<script>
    function onAdd(){
        location.href='Do/doImportClass.jsp?className='+document.getElementById('className').value;
    }

    function goback() {
        parent.location.href='import.jsp';
    }
</script>
</html>
